Technical Q&A QA1180
Where is dlopen?


Q: I can't seem to find dlopen in the Mac OS X headers. How can I dynamically link to libraries and plug-ins?

A: Mac OS X does not implement dlopen, however, it does provides a wide variety of dynamic linking choices.

  • Cocoa programmers will probably want to use NSBundle.

  • Core Foundation provides two mechanisms for dynamically linking to libraries and plug-ins on Mac OS X (CFBundle and, layered on top of that, CFPlugIn).

  • If you're working at the Darwin level you can use the dynamic linker (dyld) APIs directly. Enter "man 3 dyld", "man 1 dyld", and "man 3 NSModule" in Terminal for more details about dyld.

  • There's a third party library, dlcompat, that provides limited compatibility with dlopen and friends. This library includes source, so you can see how it implements dlopen in terms of dyld. As with all third party libraries, dlcompat is not supported by Apple.


[Aug 19 2002]


Developer Documentation | Technical Notes | Development Kits | Sample Code